{% extends 'base.html'%}
{% from 'macros.html' import form_field %}

{% block content %}
<div class="hello-form">
    <form method="post" action="{{request.full_path}}">
        {{form.csrf_token}}
        <div class="form-group required">
            {{ form_field(form.name, class='form-control')}}
        </div>
        <div class="form-group required">
            {{ form_field(form.body, class='form-control')}}
        </div>
        {{form.submit(class='btn btn-secondary')}}
    </form>
</div>
<h5>{{ messages|length }} messages
    <small class="float-right">
        <a href="#bottom" title="Go Bottom">&darr;</a>
    </small>
</h5>
<div class="list-group">
    {% for message in messages %}
        <a class="list-group-item list-group-item-action flex-column">
            <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1 text-success">{{message.name}}
                    <small class="text-muted">#{{loop.revindex}}</small>
                </h5>
                <small>
                    {{message.timestamp.strftime('%Y/%m/%d %H:%M')}}
                </small>
            </div>
            <p class="mb-1">{{message.body}}</p>
        </a>
    {% endfor %}
</div>
{% endblock %}